package jf.collections.range;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * @author ivanalx
 * @date 02.06.2009 14:35:51
 */
public class DoubleRangeIterator implements Iterator<Double> {
	private double from;
	private double to;
	private double step;
	private double current;

	public DoubleRangeIterator(double from, double to, double step) {
		this.from = from;
		this.to = to;
		this.step = step;
		this.current = from;
	}

	@Override
	public boolean hasNext() {
		return current <= to;
	}

	@Override
	public Double next() {
		if (current > to) {
			throw new NoSuchElementException();
		}
		double tmp = current;
		current += step;
		return tmp;
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}
}
